package com.cloudbroker.openapi.manage.controller;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudbroker.bcs.common.entity.HSBCPSBackNumVO;
import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.HSBCPSVO;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.result.QuestionListResult;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuesAnsListForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuesAnswerForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuesAnswerUpdateForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuestionIdForm;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.business.QuestionAnswerT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;

@Controller
public class QuestionController {
    
    @Resource
    private QuestionAnswerT2BizService questionAnswerT2;
	
	/**
     * 提问查询
     * */
    @ResponseBody
    @RequestMapping("/func_question_answer_list_by_dav")
    @SaveLog(remark = "提问查询")
    public QuestionListResult funcQuestionQry(HttpServletRequest request , String jsonpcallback){
        QuesAnsListForm form = getSingleParameterMapForBody(request , QuesAnsListForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionAnswerListByDav(form), jsonpcallback);
    }
    
    /**
     * 提问回答
     * */
    @ResponseBody
    @RequestMapping("/func_question_answer")
    @SaveLog(remark = "提问回答")
    public HSBCPSBackVO funcQuestionAnswer(HttpServletRequest request , String jsonpcallback){
        QuesAnswerForm form = getSingleParameterMapForBody(request , QuesAnswerForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionAnswer(form), jsonpcallback);
    }
    
    /**
     * 修改回复
     * */
    @ResponseBody
    @RequestMapping("/func_question_answer_update")
    @SaveLog(remark = "修改回复")
    public HSBCPSBackVO funcQuestionAnswerUpdate(HttpServletRequest request , String jsonpcallback){
        QuesAnswerUpdateForm form = getSingleParameterMapForBody(request , QuesAnswerUpdateForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionAnswerUpdate(form), jsonpcallback);
    }
    
    /**
     * 删除提问
     * */
    @ResponseBody
    @RequestMapping("/func_question_del")
    @SaveLog(remark = "删除提问")
    public HSBCPSBackVO funcQuestionDel(HttpServletRequest request , String jsonpcallback){
        QuestionIdForm form = getSingleParameterMapForBody(request , QuestionIdForm.class);
    	return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionDel(form), jsonpcallback);
    }
    
    /**
     * 公开/隐藏提问
     * */
    @ResponseBody
    @RequestMapping("/func_question_public_or_hide")
    @SaveLog(remark = "公开/隐藏提问")
    public HSBCPSBackVO funcQuestionPublicOrHide(HttpServletRequest request , String jsonpcallback){
        return VOUtil.setJsonpResult(VOUtil.genSuccessBackVo(), jsonpcallback);
    }
    
    /**
     * 获取未读问题条数
     * */
    @ResponseBody
    @RequestMapping("/func_question_noread_num")
    @SaveLog(remark = "获取未读问题条数")
    public HSBCPSBackNumVO funcQuestionNoreadNum(HttpServletRequest request , String jsonpcallback){
        HSBCPSVO form = getSingleParameterMapForBody(request , HSBCPSVO.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionNoreadNum(form), jsonpcallback);
    }

}
